package icu.d4peng.basic.satoken.controller;

import cn.dev33.satoken.stp.StpUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * SaTokenController
 *
 * @author d4peng <a href="d4peng@qq.com">d4peng@qq.com</a>
 * @since 2023.12.03
 */
@RestController
public class SaTokenController {

	@GetMapping("login")
	public String login() {
		StpUtil.login(10001);
		return "登录成功";
	}

	@GetMapping("isLogin")
	public String isLogin() {
		return "当前会话是否登录:" + StpUtil.isLogin();
	}

	@GetMapping("info")
	public String info() {
		return "当前登录信息:" + StpUtil.getTokenInfo();
	}

	@GetMapping("logout")
	public String logout() {
		StpUtil.logout();
		return "登出成功";
	}

}
